package io.gitee.yxsnake.tenant.datasource.context;

/**
 * @author: snake
 * @create-time: 2024-10-10
 * @description: 数据源上下文
 * @version: 1.0
 */
public class DataSourceContextHolder {

    private static final ThreadLocal<String> CONTEXT_HOLDER = new InheritableThreadLocal<String>();

    /**
     * 保存租户id
     * @param dbType 租户id
     */
    public static void setDBType(String dbType){
        CONTEXT_HOLDER.set(dbType);
    }

    public static String getDBType(){
        return CONTEXT_HOLDER.get();
    }

    public static void clearDBType(){
        CONTEXT_HOLDER.remove();
    }
}
